<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>课程详情</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        body {
            background: rgba(90, 194, 255, 1);
        }

        .item {
            position: relative;
            height: 200px;
            background: rgba(255, 255, 255, 1);
            box-shadow: 0px 5px 10px 0px rgba(15, 115, 174, 0.41);
            border-radius: 8px;
            margin: 15px;
            overflow: hidden;
        }

        .play {
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            margin: auto;
            width: 50px;
            height: 50px;
        }

        .content {
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 60px;
            padding: 20px 15px 0 15px;
            background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.8) 100%);
        }

        .row {
            height: 20px;
        }

        .title {
            font-size: 16px;
            font-weight: 500;
            color: rgba(255, 255, 255, 1);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .progress {
            min-width: fit-content;
            font-size: 14px;
            font-weight: 400;
            color: rgba(255, 255, 255, 1);
            text-align: right;
            margin-left: 25px;
        }

        .tips {
            margin-top: 10.5rem;
            color: #fff;
            font-size: 14px;
            font-weight: 400;
        }
    </style>
</head>

<body>
    <div class="vueApp" v-cloak>
        <div class="item" v-for="item in listData" @click="handleItem(item)">
            <img class="play" src="../../image/ui/play.png" alt=" ">
            <img :src="item.dubAudioUrl + '?x-oss-process=video/snapshot,t_100,m_fast'" alt="">
            <div class="content">
                <div class="row" data-flex="main:justify cross:center">
                    <div class="title" data-flex-box="1 ">{{ item.dubName }}</div>
                    <div class="progress">{{item.timeNum|transFormat}}</div>
                </div>
            </div>
        </div>
        <div class="tips" data-flex="cross:center main:center" v-show="tipsShow">
            没有更多数据了
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js "></script>
<script type="text/javascript" src="../../script/service/service-tool.js "></script>
<script type="text/javascript" src="../../script/service/service-app.js "></script>
<script type="text/javascript" src="../../script/service/service-user.js "></script>
<script type="text/javascript" src="../../script/service/service-logic.js "></script>
<script type="text/javascript" src="../../script/jquery.min.js "></script>
<script type="text/javascript" src="../../script/vue.min.js "></script>
<script type="text/javascript">
    // html 的引号一律为双引号(" "),js 为单引号('')
    var USER, $S, vm;
    apiready = function () {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');

        fnInit();
    };
    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                pageNo: 1,
                pageSize: 10,
                listData: [],
                tipsShow: false
            },
            filters: {
                transFormat: function(duration) {
                    if(duration) {
                        var time = parseInt(duration);
                        var s = time % 60,
                            m = (time - s) / 60;
                        return (m > 9 ? m : '0' + m) + ':' + (s > 9 ? s : '0' + s);
                    }else {
                        return '0:00';
                    }
                }
            }
        });
        load();
    }

    function load() {
        getPageData('headerRefreshing');
        fnAddHeaderRefreshingEvent(function() { //设置下拉刷新
            getPageData('headerRefreshing');
        });

        fnAddFooterLoadingEvent(function() { // 设置上拉加载
            getPageData('load');
        });

    }

    function getPageData(sign) {
        if(sign == 'headerRefreshing') {
            vm.pageNo = 1;
        } else {
            vm.pageNo ++;
        }
        var url = 'question/myKaraoke';
        var params = {
            'pageSize': vm.pageSize,
            'pageNo': vm.pageNo
        };
        var callback = function(data) {
            if(vm.pageNo == '1') {
                vm.listData = [];
            }
            api.refreshHeaderLoadDone();
            vm.listData = vm.listData.concat(data.listData);
            vm.$nextTick(function() {
                if(vm.listData.length === 0) {
                    vm.tipsShow = true;
                } else {
                    vm.tipsShow = false;
                }
            })
            // status 为200时,只返回data
        };
        POST(url, params, callback);
    }

    function handleItem(item) {
        fnOpenPublicWin(item.dubName, 'course1/karaoke_detail', {
            video: item.dubAudioUrl,
            id: item.id,
            code: '',
            questionName: item.dubName
        });
    }
</script>

</html>